In [56]:
from IPython import parallel
import numpy
c = parallel.Client()
dv = c[:]
dv.block = True
lv = c.load_balanced_view()
lv.block = True
with dv.sync_imports():
from time import sleep
n_engines = len(dv)
n_per_engine = 5
times = numpy.random.random(n_engines * n_per_engine)
print 'total:', times.sum()
print 'direct:', max(arr.sum() for arr in numpy.split(times, n_engines))
print 'optimal:', times.sum() / n_engines
print times
In [57]:
def f (t):
sleep(t)
%timeit dv.map(f, times)
%timeit lv.map(f, times)